/*
 * @Description: 主组件
 * @Author: mofish
 * @Date: 2022-05-27
 * @LastEditTime: 2022-05-27
 * @LastEditors: mofish
 */
import { useRoutes } from 'react-router-dom'
import EasyCore from './core'
import { EasyRoutePropsType } from '../../types'

function EasyRouter (
  {
    routes,
    beforeRouteEnter,
    loading,
  } : EasyRoutePropsType
) {
  const core  = new EasyCore({
    routes,
    beforeRouteEnter,
    loading,
  })
  const reactRoutes = core.transformRoutes()
  const elements = useRoutes(reactRoutes)

  return elements
}

export default EasyRouter